Sheffield | 26-ITP-Jan | Seti Mussa | Sprint 2 | Coursework#1217
Sheffield | 26-ITP-Jan | Seti Mussa | Sprint 2 | Coursework#1217Seti-Jemal wants to merge 6 commits intoCodeYourFuture:mainfrom
Conversation
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
| // This might help https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase | ||
|
|
||
| function convertToUpperSnakeCase(str) { | ||
| return str.toUpperCase().trim().split("").join("_"); |
There was a problem hiding this comment.
This works.
Could also consider using the string's methods .replaceAll() or replace().
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| const toPounds = (kg) => +(kg * 2.20462).toFixed(2); | ||
|
|
||
| const penceToPounds = (p) => `£${(p / 100).toFixed(2)}`; | ||
| const toUpperSnakeCase = (s) => s.toUpperCase().trim().split(" ").join("_"); | ||
| const multiply = (a, b) => a * b; |
There was a problem hiding this comment.
-
Why implement 4 different functions in this file?
-
The input to the code in Sprint-1 is a "pence string" in the form "399p" (with a trailing 'p'). The function on line 10 would not work properly if the given
pis a string in this format. Can you update the function accordingly so that your function can return"£3.99"when the given argument is"399p"?
| // | ||
| // The penceToPounds function was updated to handle a pence string like "399p". | ||
| // It removes the "p", converts the value to a number, and divides by 100 | ||
| // so the function correctly returns "£3.99".s |
There was a problem hiding this comment.
Have you tried calling penceToPounds("399p") to see if it can successfully return "£3.99"?
// Four functions are implemented because each one performs a specific task.
// This makes the code easier to read, reuse, and maintain.
However, three of the functions are not needed for converting pence string to pound string.
Perhaps you want to keep them in the file they belong to? Or keep them in separate file on your computer (if you want to save them for use later)?
Self checklist
Changelist
Completed sprint 2